#coding:utf-8



import base
from base import CUSTOM
from datamethod import asc2data, data2asc




#1022 车台版本查询
class Buss1022(base.Buss):
    busstype = [0x10, 0x22]
    name = u"车台版本查询"
    
    def play(self, hunter):
        hunter.sendData(self.getType(), self.getData())
        hunter.requestVersion()

#1062 车台版本查询应答
class Buss1062(base.Buss):
    busstype = [0x10, 0x62]
    def init(self):
        self.version = []
        
    def separate(self, data):
        length = data.get(1)
        self.version = data.get(length)
    
    def assemble(self, data):
        data.set(len(self.version), self.version)
        
    def getVersion(self):
        return base.data2unicode(self.version)
        
    def setVersion(self, value):
        if isinstance(value, str):
            self.version = base.asc2data(value)
        else:
            self.version = base.unicode2data(value)
    
    def play(self, hunter):
        hunter.responseVersion(self.getVersion())
        
    
class Hunter(base.HunterMaster):
    name = u'千里眼版本查询'
    operation = (Buss1022, )          
    wanted = (Buss1022, Buss1062)
    
    def requestVersion(self):
        pass
    
    def responseVersion(self, version):
        pass
    
    def interpret(self, reportList, windowParent):
        pass
    